def load_bordered_grids(filename):
  # return a [string]
  file = open(filename,'r')
  lines = file.readlines()
  i = 0
  buffer = []
  results = []
  while i<len(lines):
    if lines[i].strip()=='':
      if len(buffer)>0:
        results.append(buffer)
        buffer = []
      i=i+1
      continue
    buffer.append(lines[i].strip())
    i=i+1
  if len(buffer)>0:
    results.append(buffer)  
  file.close()
  return results

dump = open(path+'..\\dump.txt','w')
print path+'..\\dump.txt'
for file in os.listdir(r'C:\roguelike\orbquest\templates'):
    if file<>".svn":
        bordered_grids = load_bordered_grids(path+file)
        for grid in bordered_grids:
            dump.write("\nbasic_templates.append(Template(\"\"\"\n")
            for line in grid:
                dump.write(line+'\n')
            dump.write("\"\"\"),raw_prob=0.3)\n\n")
dump.close()
